import sys

from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtCore import QTimer

app = QApplication(sys.argv)

message_box = QMessageBox()
message_box.setText("这是一个自动消失的信息")
message_box.setIcon(QMessageBox.Information)

# 设置非模态
message_box.setWindowModality(QtCore.Qt.WindowModality.NonModal)
message_box.show()

# 定时关闭
timer = QTimer()
timer.singleShot(1000, message_box.close)  # 5秒后自动关闭

sys.exit(app.exec_())